#include <string>
#include <vector>
#include <stdarg.h>

#define _MAX_CHARS 8192

namespace STRING_UTIL
{
	inline int Format(std::string& strDest, const char* szFormat,...)
	{
		std::vector<char> _buffer( _MAX_CHARS );

		va_list argList;
		va_start( argList, szFormat);

		int ret = vsnprintf( &_buffer[0], _MAX_CHARS, szFormat, argList );

		va_end( argList );

		strDest.assign( &_buffer[0], ret );

		return ret;
	};

	inline const char * valueForKey(const char *key, CCDictionary<std::string, CCObject*> *dict)
	{
		if (dict)
		{
			CCString *pString = (CCString*)dict->objectForKey(std::string(key));
			return pString ? pString->m_sString.c_str() : "";
		}
		return "";
	};

	/*inline std::string GetStageFileName(int nStage)
	{
		std::string strKey;
		std::string fileName;
		STRING_UTIL::Format( strKey, "stage%d", nStage );
		
		CCDictionary<std::string, CCObject*> *pDic = CCFileUtils::dictionaryWithContentsOfFile(STAGE_INFO_FILE);
		
		if(!pDic)
			return NULL;

		CCString* pString = (CCString*)pDic->objectForKey( strKey.c_str() );

		if( pString )
		{
			fileName = pString->toStdString();
		}

		return fileName;
	}*/
}